const express = require('express')

const app = express()

let mwAll = (req, res, next) => {
    console.log('这是全局中间件')
    next()
}

let mw1 = (req, res, next) => {
    console.log('mw1 run')
    next()
}

let mw2 = (req, res, next) => {
    console.log('mw2 run')
    next()
}

app.use(mwAll)

app.get('/home', (req, res) => {
    res.send('get home send')
})

app.get('/index', [mw1, mw2], (req, res) => {
    res.send('get index send')
})

app.listen(8080, () => {
    console.log('8080, running')
})